home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 8
/
Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso
/
Aminet
/
util
/
cli
/
vAvail.lha
/
vAvail
/
vAvail.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-09-06
|
4KB
|
145 lines
/*
* $VER:vAvail.c 2.0 (06.09.95) 10:06:37 Copyright © 1995 by Sylvain ROUGIER
*
* Created: 19 Jun 1995 14:19:05
* Modified: 06 Sep 1995 10:06:03
*
* Make>> sc <file>.c
* Make>> slink LIB:cs.o <file>.o SmallCode SmallData BATCH NOICONS TO <file> LIB LIB:c.lib
*
*
*/
#include <clib.h>
#include <VMM_Stat.h>
#include <libraries/VMem.h>
#include <proto/VMem.h>
// Startup Modules...
CliArgs; ParseToolTypes;
char *Template = "CHIP/S,FAST/S,VMM/S,GigaMem/S,TOTAL/S,FLUSH/S";
char *CliHelp;
enum ARG_ { ARG_Chip = 0, ARG_Fast, ARG_VMM, ARG_GigaMem, ARG_Total, ARG_Flush};
#define MEMF_PHYS MEMF_PUBLIC
char *VersTag = "$VER:vAvail 2.0 (19.06.95) 17:54:20 Copyright © 1995 by Sylvain ROUGIER";
long Main( char *ArgV[], struct WBStartup *WBenchMsg)
{
ULONG AvailChip = 0;
ULONG MaximumChip = 0;
ULONG LargestChip = 0;
ULONG AvailFast = 0;
ULONG MaximumFast = 0;
ULONG LargestFast = 0;
ULONG AvailVMM = 0;
ULONG MaximumVMM = 0;
ULONG LargestVMM = 0;
ULONG AvailGigaMem = 0;
ULONG MaximumGigaMem = 0;
ULONG LargestGigaMem = 0;
ULONG AvailTotal = 0;
ULONG MaximumTotal = 0;
ULONG LargestTotal = 0;
if ( ArgV[ ARG_Flush])
{
UBYTE *Mem;
if ( Mem = AllocVec( 0x7FFFFFFF, MEMF_ANY))
FreeVec( Mem);
}
AvailChip = AvailMem( MEMF_CHIP);
MaximumChip = AvailMem( MEMF_CHIP|MEMF_TOTAL);
LargestChip = AvailMem( MEMF_CHIP|MEMF_LARGEST);
AvailFast = AvailMem( MEMF_FAST|MEMF_PHYS);
MaximumFast = AvailMem( MEMF_FAST|MEMF_PHYS|MEMF_TOTAL);
LargestFast = AvailMem( MEMF_FAST|MEMF_PHYS|MEMF_LARGEST);
AvailTotal = AvailMem( MEMF_ANY);
MaximumTotal = AvailMem( MEMF_ANY|MEMF_TOTAL);
LargestTotal = AvailMem( MEMF_ANY|MEMF_LARGEST);
// VMM suport
{
struct VMStatMsg *VMStatMsg;
LONG VMSignal;
struct MsgPort *VMPort;
if ( VMStatMsg = AllocVec( sizeof( struct VMStatMsg), MEMF_PUBLIC))
{
if ( -1L != ( VMSignal = AllocSignal( -1L)))
{
VMStatMsg->VMMessage.mn_Length = sizeof( struct VMStatMsg);
VMStatMsg->Sender = FindTask( NULL);
VMStatMsg->Command = VMCMD_AskStat;
VMStatMsg->ReplySignal = VMSignal;
Forbid();
if( VMPort = FindPort( "VMM_Port"))
PutMsg( VMPort, (struct Message*)VMStatMsg);
else
;
Permit();
if ( VMPort)
{
Wait (1L << VMSignal);
// Now VMStat are filled with right info.
AvailVMM = VMStatMsg->VMFree;
MaximumVMM = VMStatMsg->VMSize;
LargestVMM = AvailVMM; // no way to find it
}
FreeSignal( VMSignal);
}
FreeVec( VMStatMsg);
}
}
//GigaMem support
{
struct Library *VMemBase;
if ( VMemBase = OpenLibrary( "vmem.library", 0))
{
AvailGigaMem = VMAvailMem( 0,0);
CloseLibrary( VMemBase);
}
}
if ( ArgV[ ARG_Chip])
Printf( "%lu\n", AvailChip);
else if ( ArgV[ ARG_Fast])
Printf( "%lu\n", AvailFast);
else if ( ArgV[ ARG_VMM])
Printf( "%lu\n", AvailVMM);
else if ( ArgV[ ARG_GigaMem])
Printf( "%lu\n", AvailGigaMem);
else if ( ArgV[ ARG_Total])
Printf( "%lu\n", AvailTotal);
else
{
Printf( "Type Available In-Use Maximum Largest\n");
//Printf( "Fast %l11U %l11U %l11U %l11U\n", 111222333L, 111222L, 333222111L, 0L);
Printf( "Chip %l11U %l11U %l11U %l11U\n", AvailChip, MaximumChip - AvailChip, MaximumChip, LargestChip);
Printf( "Fast %l11U %l11U %l11U %l11U\n", AvailFast, MaximumFast - AvailFast, MaximumFast, LargestFast);
if ( MaximumVMM > 0)
Printf( "VMM %l11U %l11U %l11U %l11U\n", AvailVMM, MaximumVMM - AvailVMM, MaximumVMM, LargestVMM);
if ( MaximumGigaMem > 0)
Printf( "GM %l11U %l11U %l11U %l11U\n", AvailGigaMem, MaximumGigaMem - AvailGigaMem, MaximumGigaMem, LargestGigaMem);
Printf( "Total %l11U %l11U %l11U %l11U\n", AvailTotal, MaximumTotal - AvailTotal, MaximumTotal, LargestTotal);
}
return 0;
}